﻿<title>用户</title>
<link type="text/css" href="${ctx}/resources/css/ace.min.1.css"  rel="stylesheet" />
<table>
<tr>
<th>用户状态 :</th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/user/list${suffix}" >不限</a> </th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/user/list${suffix}?state=1" >正常</a> </th>
<th width="70px;" class="label label-sm label-warning arrowed"> <a href="${ctx}/admin/user/list${suffix}?state=2" >禁用</a> </th>
</tr>
</table>
<#--
<form class="form-horizontal" role="form" id="validation-form" method="POST" action="${ctx}/admin/user/list" onsubmit="return fromSearch(this)">
	<input type="hidden" name="pager" value="1_"/>
	<label>手机号:</label>
	<input name="contact" value="${(pager.searchMap.contact)!''}" placeholder="输入手机号" maxlength="64" style="height: 36px; width: 160px; padding-left: 10px;" autocomplete="off">
	<label>用户名称:</label>
	<input name="userName" value="${(pager.searchMap.userName)!''}" placeholder="用户名称" maxlength="64" style="height: 36px; width: 160px; padding-left: 10px;" autocomplete="off">

	<input type="submit" value="搜索一下" style="
		width: 100px;
		border: 0;
	    padding: 0;
	    height: 36px;
	    color: white;
	    font-size: 15px;
	    letter-spacing: 1px;
	    background: #3385ff;
	    border-bottom: 1px solid #2d78f4;
	    outline: medium;
	    -webkit-appearance: none;
	    -webkit-border-radius: 0;"
    />
</form>-->
<div class="hr hr-5"></div>
<div class="row">
	<div class="col-xs-12">
		<div class="table-responsive">
			<table id="sample-table-1" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th>ID</th>
						<th>昵称 / 真实姓名</th>
						<th>友邻号</th>
						<th>手机号</th>
						<th>类型</th>
						<th>状态</th>
						<th>注册时间</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<#list pager.itemList as u>
					<tr>
						<td>${u.id}</td>
						<td>${u.userName!} / ${u.realName!}</td>
						<td>${u.friendlyNo!}</td>
						<td>${u.contact!}</td>
						<td>
							<span class="label label-sm label-warning arrowed">
								${dicSetting.getParameterValue("user.role." + u.roleType)}
							</span>
						</td>
						<td>
						<#if u.state == 2>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doUserState(this,'${u.id}');" id="off_state"/>
							<span class="lbl"></span>
						<#else>
							<input name="switch-field-1" class="ace ace-switch ace-switch-4" type="checkbox" onchange="doUserState(this,'${u.id}');" checked="checked" id="off_state"/>
							<span class="lbl"></span>
						</#if>
						</td>
						<td>
						<#if u.createTime??>
							${tagUtils.formatDate(u.createTime)!}
						</#if>
						</td>
						
						<td>
						<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
							<a class="green" href="${ctx}/admin/user/${u.id}/detail${suffix}">
								查看详情
							</a>
							<a class="green" href="${ctx}/admin/user/address-${u.id}${suffix}">
								地址管理
							</a>
						</div>
						</td>
					</tr>
				</#list>
				</tbody>
			</table>
		</div>
	
		<div class="hr hr-18 dotted hr-double"></div>
		<@h.page pager=pager action="${ctx}/admin/user/list${suffix}" />
	</div><!-- /span -->
</div><!-- /row -->

<#if errorMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer red"></i>
		<span class="pink">${errorMsg!}</span>
	</h4>
</#if>

<#if infoMsg??>
	<div class="hr hr-18 hr-double dotted"></div>
	<h4 class="lighter">
		<i class="icon-hand-right icon-animated-hand-pointer green"></i>
		<span class="pink">${infoMsg}</span>
	</h4>
</#if>

<script>
function fromSearch(f){
	if(f.contact.value) {
		f.pager.value += "$$contact--" + f.contact.value.trim();
	}
	if(f.userName.value) {
		f.pager.value += "$$userName--" + f.userName.value.trim();
	}
	return true;
}
function doUserState(checkbox,id) {
		if(checkbox.checked) {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/user/on?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		} else {
			$.ajax({
			async : false,
	        cache : false,
	        type : 'POST',
	        dataType :JSON,
	        url : "${ctx}/admin/user/off?id="+id,
	        error : function(data){
	        	var str = data.responseText;
	        	if(str.indexOf("true")>0){
    				location.href = location.href;
    			}else{
    			}
	        }
			});
		}
	}
$(document).ready(function(){
	RP.addBreadcrumb([{name:"基础配置"}, {name:"用户管理", active: true}]);
});
</script>